package com.demo.security.utils.jackson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JacksonArray extends ArrayList<JacksonObject> {

	private static final long serialVersionUID = 9123945244282661987L;

	public JacksonArray() {
		super();
	}

	public JacksonArray(List<JacksonObject> list) {
		super(list);
	}

	@Override
	public String toString() {
		return JacksonUtils.toJsonString(this);
	}

	public static void main(String[] args) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("a", "aaa");
		map1.put("b", 111);
		list.add(map1);

		String json = JacksonUtils.toJsonString(list);
		System.out.println(json);

		JacksonArray array = JacksonUtils.toJsonArray(json);
		System.out.println(array);

		JacksonObject obj = array.get(0);
		System.out.println(obj);

		array.forEach(item -> {
			System.out.println(item.getString("a"));
		});
	}
}
